#ifndef ITERATOR_PATTERN_H
#define ITERATOR_PATTERN_H

#include <string>
#include <vector>

using namespace std;

class NameRepository;

class Iterator
{
public:
    virtual ~Iterator() {}
    virtual bool hasNext() = 0;
    virtual void next() = 0;
    virtual string currentItem() = 0;
};

class NameIterator : public Iterator
{
public:
    NameIterator(NameRepository* l);
    ~NameIterator();

    bool hasNext() override;
    void next() override;
    string currentItem() override;

private:
    NameRepository* l;
    int index;

};

class Container
{
public:
    virtual ~Container() {}

    virtual Iterator* getIterator() = 0;
};

class NameRepository : public Container
{
public:
    NameRepository(int size);
    ~NameRepository() {}
    Iterator * getIterator() override;

    int size();
    string at(int index);
    void show();

private:
    string list[4];
    int count;
};

#endif // ITERATOR_PATTERN_H

/*
    NameRepository* l = new NameRepository(4);

    Iterator* it = l->getIterator();
    for(; it->hasNext(); it->next())
    {
        cout << it->currentItem() << endl;
    }
    */
